package es.app.util;

import java.lang.reflect.Field;


public abstract class Bean {
	
	public String toXML(){
		StringBuffer buffer = new StringBuffer();
		buffer.append("<"+getClass().getSimpleName()+">");
		Field[] atributos = getClass().getDeclaredFields();
		for(Field f : atributos){
			String attr = f.getName();
			if(!attr.equals("serialVersionUID")){
				buffer.append("<"+attr+">");
				try{
					f.setAccessible(true);
					String value = f.get(this).toString();
					buffer.append(value);
				}catch(Exception e){
					System.out.println(e.getMessage());
				}
				buffer.append("</"+attr+">");
			}
		}
		buffer.append("</"+getClass().getSimpleName()+">");
		return buffer.toString();
	}

}
